package com.xszx.serviceedu.controller;

import com.xszx.commonutils.R;
import com.xszx.serviceedu.entity.Course;
import com.xszx.serviceedu.entity.Teacher;
import com.xszx.serviceedu.service.CourseService;
import com.xszx.serviceedu.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: 白熊
 * @Date: 2024/7/22 16:39
 */
@Api("前端Banner首页讲师和课程的展示管理")
//@CrossOrigin
@RestController
@RequestMapping("/serviceedu/index")
public class IndexController {
    @Autowired
    private TeacherService teacherService;
    @Autowired
    private CourseService courseService;

    //查询前8条热门课程，查询前4条名师
    @ApiOperation("查询前八条课程信息前四条讲师信息")
    @GetMapping
    public R get(){
        //查询前八条课程信息
        List<Course> courseList = courseService.indexList();
        //查询前四条讲师信息
        List<Teacher> teacherList = teacherService.indexTeacher();
        return  R.ok().data("courseList",courseList)
                .data("teacherList",teacherList);
    }
}
